import React, { Component } from 'react'
import { Link,Switch,Route } from 'react-router-dom'
import Detail from './Detail'
export default class Message extends Component {

    state ={
        messageArr:[
            {id:'01',title:'消息1'},
            {id:'02',title:'消息2'},
            {id:'03',title:'消息3'}
        ]
    }

  render() {
    const {messageArr} =this.state
    return (
      <div>
        <ul>

            {
                messageArr.map((msgObj)=>{
                    
                    return <li key={msgObj.id}>
                        <Link to={`/home/message/detail/${msgObj.id}/${msgObj.title}`} >{msgObj.title}</Link>
                    </li>

                })
            }

            

            {/* <li> 
                <a href="/message1">message1</a>&nbsp;&nbsp;
            </li>
            <li> 
                <a href="/message2">message2</a>&nbsp;&nbsp;
            </li>
            <li> 
                <a href="/message3">message3</a>&nbsp;&nbsp;
            </li> */}
        </ul>
        <Switch>
            <Route path='/home/message/detail/:id/:title' component={Detail}></Route>
        </Switch>
      </div>
    )
  }
}
